home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS Toolkit
/
BBS Toolkit.iso
/
rbbs_pc
/
overm82.zip
/
MSG2TXT.ZIP
/
MSG2TXT.BAS
next >
Wrap
BASIC Source File
|
1990-01-16
|
5KB
|
194 lines
DECLARE SUB Prints (A$, num.returns%)
DECLARE SUB Print1 (A$)
DECLARE SUB Trim (A$)
' MSG2TXT.BAS
'------------------------------------------------------------------------
'
' Program to convert a RBBS Messages file to text format
'
' Tom Collins
' 01-15-90
'
'$INCLUDE: 'c:qb.bi'
CONST TRUE = -1
CONST FALSE = 0
DEFINT A-Z
TYPE Checkpoint ' RBBS checkpoint message record
LastMsgNum AS STRING * 8 ' high message number on the system
AutoAddSec AS STRING * 2
CallerNum AS STRING * 10
Reserved1 AS STRING * 36
NumUserRecsUsed AS STRING * 5
Reserved2 AS STRING * 6
FirstRec AS STRING * 7 ' first messages record that contains a message
NextAvailRec AS STRING * 7 ' next messages record that can be written to
LastRec AS STRING * 7 ' last record in messages file
MaxNumMsgs AS STRING * 7 ' max # of messages this file can handle
Reserved3 AS STRING * 31
NumNodes AS STRING * 2
END TYPE
TYPE Header ' RBBS message header record
ReadOnly AS STRING * 1
MsgNumber AS STRING * 4
MsgFrom AS STRING * 31
MsgTo AS STRING * 22
Time AS STRING * 8
Reserved AS STRING * 1
Date AS STRING * 8
MsgSubject AS STRING * 25
Password AS STRING * 15
Active AS STRING * 1
RecsInMsg AS STRING * 4
MinSecToRead AS STRING * 2
DateLastRead AS STRING * 3
TimeLastRead AS STRING * 3
END TYPE
TYPE Text
MsgTxt AS STRING * 128
END TYPE
DIM Chkpt AS Checkpoint
DIM Hdr AS Header
DIM T AS Text
RBBS.Eol$ = CHR$(227)
ON ERROR GOTO 9999
A$ = COMMAND$
CALL Trim(A$)
I = INSTR(A$, " ")
IF (LEN(A$) = 0 OR I = 0) THEN
PRINT "Usage: Messages_File_Name Text_File_Name"
END
ELSE
Messages.File$ = LEFT$(A$, I)
Text.File$ = MID$(A$, I)
CALL Trim(Messages.File$)
CALL Trim(Text.File$)
END IF
90 OPEN "CONS:" FOR OUTPUT AS #1
CALL Prints("MSG2TXT v0.01 01-15-90 - Super Dooper RBBS Message to Text Converter", 2)
CALL Prints("Input File : " + Messages.File$, 1)
CALL Prints("Output File: " + Text.File$, 2)
100 OPEN "R", 3, Messages.File$, 128
101 OPEN Text.File$ FOR OUTPUT AS #2
102 GET 3, 1, Chkpt
First.Rec = VAL(Chkpt.FirstRec)
Last.Rec = VAL(Chkpt.LastRec)
Next.Avail.Rec = VAL(Chkpt.NextAvailRec)
I = First.Rec
Msgs.Processed = 0
Recs.to.Process = Next.Avail.Rec - First.Rec
CALL Prints("Records to Process:" + STR$(Recs.to.Process), 1)
Recs.Processed = 0
Lines.Printed = 0
CALL Print1(CHR$(12) + "MSG2TXT Conversion: " + Messages.File$ + " -> " + Text.File$)
CALL Print1(" Converted: " + DATE$ + " " + TIME$)
CALL Print1("")
CALL Print1("")
DO
103 GET 3, I, Hdr
recs.in.msg = VAL(Hdr.RecsInMsg)
IF recs.in.msg <= 0 THEN
recs.in.msg = 1
END IF
CALL Print1(" Msg #: " + Hdr.ReadOnly + Hdr.MsgNumber)
CALL Print1(" From: " + Hdr.MsgFrom + " Sent: " + Hdr.Date + " " + LEFT$(Hdr.Time, 5))
CALL Print1(" To: " + Hdr.MsgTo + SPACE$(9) + " Rcvd: -NO-")
CALL Print1(" Subj: " + Hdr.MsgSubject)
CALL Print1("")
One.Line$ = ""
Txt$ = ""
FOR J = 1 TO recs.in.msg
104 GET 3, I + J, T
Txt$ = Txt$ + MID$(T.MsgTxt, 1, 128)
NEXT
k = INSTR(Txt$, RBBS.Eol$)
IF k = 0 THEN
CALL Print1("")
ELSE
DO WHILE k <> 0
One.Line$ = LEFT$(Txt$, k - 1)
IF LEFT$(One.Line$, 1) <> CHR$(1) AND LEFT$(One.Line$, 8) <> "SEEN-BY:" THEN
CALL Trim(One.Line$)
CALL Print1(One.Line$)
One.Line$ = ""
END IF
Txt$ = MID$(Txt$, k + 1)
k = INSTR(Txt$, RBBS.Eol$)
LOOP
One.Line$ = Txt$
END IF
CALL Print1("")
I = I + recs.in.msg
Msgs.Processed = Msgs.Processed + 1
Recs.Processed = Recs.Processed + recs.in.msg
CALL Prints(STR$(Msgs.Processed) + " Msgs " + STR$(Recs.Processed) + " Recs" + CHR$(13), 0)
LOOP WHILE I < Next.Avail.Rec
CALL Prints("Done Processing ", 1)
CLOSE
END
9999 PRINT
SELECT CASE ERL
CASE 100
A$ = "Error opening Messages File '" + Messages.File$ + "'"
CASE 101
A$ = "Error opening Text File '" + Text.File$ + "'"
CASE 102, 103, 104
A$ = "Error Reading Messages File"
END SELECT
A$ = A$ + " - Program Aborted"
PRINT A$
CLOSE
END
SUB Print1 (A$)
'
' Prints a string on the screen through the "CON" device
'
SHARED Lines.Printed
PRINT #2, A$
Lines.Printed = Lines.Printed + 1
IF Lines.Printed = 60 THEN
Lines.Printed = 0
PRINT #2, CHR$(12); ' Form feed
PRINT #2,
PRINT #2,
PRINT #2,
END IF
END SUB
SUB Prints (A$, num.returns)
'
' Prints a string on the screen through the "CON" device
'
PRINT #1, A$;
FOR I = 1 TO num.returns
PRINT #1,
NEXT I
END SUB
SUB Trim (A$)
'
' Removes left and right spaces from a string
'
A$ = LTRIM$(A$)
A$ = RTRIM$(A$)
END SUB